package com.android.equipment.adapter

import com.android.equipment.R
import com.android.equipment.bean.TeamGroupRelevanceData
import com.android.equipment.custom.RoundImage
import com.blankj.utilcode.util.StringUtils
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.jet.flowtaglayout.FlowTagLayout

class PeopleInfoAdapter(resId: Int): BaseQuickAdapter<TeamGroupRelevanceData,BaseViewHolder>(resId) {
    override fun convert(holder: BaseViewHolder, item: TeamGroupRelevanceData) {
        holder.setText(R.id.tv_people_name,item.peopleName)
        holder.setText(R.id.tv_people_phone,item.peoplePhone)
        val peoplePhoto = item.peoplePhoto
        val ivPhoto = holder.getView<RoundImage>(R.id.iv_photo)
        if (!StringUtils.isEmpty(peoplePhoto)) {
            Glide.with(context)
                .load("file://$peoplePhoto") // 使用 file:// URI 加载本地图片
                .into(ivPhoto)
        }
        if (item.devices.isNotEmpty()){
            val flowTagLayout = holder.getView<FlowTagLayout>(R.id.flowTagLayout)
            flowTagLayout.addTags(item.devices.map {
                "${it.deviceName}${it.deviceCode}"
            })
        }

    }
}